package gui;

import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
import org.eclipse.wb.swt.SWTResourceManager;

import data.model.Project;
import data.model.ProjectCharacteristics;

public class ProjectOverviewComposite extends Composite {

	private final Project project;

	/**
	 * Create the composite.
	 * 
	 * @param parent
	 * @param style
	 */
	public ProjectOverviewComposite(Composite parent, int style,
			Project project, ProjectCharacteristics projectHealthCriteria) {
		super(parent, SWT.NONE);

		if (project == null) {
			throw new IllegalArgumentException("project must not be null");
		}
		this.project = project;
		setLayout(new GridLayout(3, false));

		Label lblProjectName = new Label(this, SWT.NONE);
		lblProjectName.setFont(SWTResourceManager.getFont("Segoe UI", 16,
				SWT.BOLD));
		GridData gd_lblProjectName = new GridData(SWT.FILL, SWT.TOP, true,
				false, 1, 2);
		gd_lblProjectName.widthHint = 150;
		lblProjectName.setLayoutData(gd_lblProjectName);

		Composite projectCharacteristicsComposite = new ProjectCharacteristicsComposite(
				this, SWT.NONE, project, projectHealthCriteria);
		projectCharacteristicsComposite.setLayoutData(new GridData(SWT.LEFT,
				SWT.TOP, false, false, 1, 2));

		Composite progressComposite = new ProgressComposite(this, SWT.NONE,
				project.getProgressInPercent());
		progressComposite.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, false,
				false, 1, 1));

		Label lblWeek = new Label(this, SWT.NONE);
		lblWeek.setText("  Week " + project.getFirstWeekNumberWithoutData()
				+ " of " + project.getDurationInWeeks());

		Label horizontalLine = new Label(this, SWT.SEPARATOR | SWT.HORIZONTAL);
		GridData gd_horizontalLine = new GridData(SWT.FILL, SWT.CENTER, true,
				false, 3, 1);
		gd_horizontalLine.widthHint = 368;
		horizontalLine.setLayoutData(gd_horizontalLine);

		// initialize
		lblProjectName.setText(project.getId());
	}
}
